/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */

 //使用递归的方法判断
class Solution {
public:
    bool recur(TreeNode* Node1,TreeNode* Node2)
    {
        if(!Node1&&!Node2) return true;
        if(!Node1||!Node2||Node1->val!=Node2->val) return false;
        return recur(Node1->left,Node2->right)&&recur(Node1->right,Node2->left); 
    }
    bool isSymmetric(TreeNode* root) {
        return root==nullptr||recur(root->left,root->right);
    }
};
